/*
 *  Copyright (C) 2009 Dominik Psenner, Christoph Caks
 * 
 *   This file is part of project-blog.
 *
 *  project-blog is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  project-blog is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with project-blog.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.blog.model;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.persistence.OneToMany;

import com.google.appengine.api.datastore.Key;

/**
 * 
 * @author Christoph Caks
 * 
 */

public class Blog implements Serializable {
	
	private static final long serialVersionUID = 7808689665455643261L;
	
	@SuppressWarnings("unused")
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	
	@Persistent
	private String title;
	
	@Persistent
	private Date creation;
	
	@OneToMany(mappedBy = "blog")
	private Set<Article> articles;
	
	public String getTitle() {
		return title;
	}
	
	public void setTitle(final String title) {
		this.title = title;
	}
	
	public Date getCreation() {
		return creation;
	}
	
	public void setCreation(final Date creation) {
		this.creation = creation;
	}
	
	public void addArticle(final Article a) {
		articles.add(a);
	}
	
	public void removeArticle(final Article a) {
		articles.remove(a);
	}
	
	public void clearArticles() {
		articles.clear();
	}
	
	public Set<Article> getArticles() {
		return Collections.unmodifiableSet(articles);
	}
	
	public void setArticles(final Set<Article> articles) {
		this.articles = articles;
	}
	
}
